package com.han.controller;

import com.han.count.Zh0202UserCount;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.thymeleaf.util.StringUtils;

/**
 * @author: zh
 * @date: 2021/11/19 22:07
 * @version: 1.0
 */
@Controller
public class LoginController {

    private Integer count=0;
    private static Zh0202UserCount userCount=null;

    public static void countUser(){
        userCount=Zh0202UserCount.getInstance();
    }

    @RequestMapping("/user/login")
    public String login(@RequestParam("username") String username,
                        @RequestParam("password") String password,
                        Model model) {
        countUser();
        count=userCount.getCount();
        if (!StringUtils.isEmpty(username) && "123456".equals(password)) {
            model.addAttribute("members",count);
            return "dashboard";
        } else {
            /*model.addAttribute("msg","用户名或者密码不正确");
            return "index";*/
        }
        return "index";
    }
}
